﻿Public Class RrangoEdad

    Public Shared Function SeleccionarTodo(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of ErangoEdad)
        Dim rangoEdades As List(Of ErangoEdad) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                rangoEdades = DrangoEdad.SeleccionarTodo(descEmpresa)
                If rangoEdades Is Nothing Then rangoEdades = New List(Of ErangoEdad)
                If DisplaySelect Then rangoEdades.Insert(0, New ErangoEdad("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return rangoEdades
    End Function
    Public Shared Function SeleccionarXEstado(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of ErangoEdad)
        Dim rangoEdades As List(Of ErangoEdad) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                rangoEdades = DrangoEdad.SeleccionarXEstado(descEmpresa)
                If rangoEdades Is Nothing Then rangoEdades = New List(Of ErangoEdad)
                If DisplaySelect Then rangoEdades.Insert(0, New ErangoEdad("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return rangoEdades
    End Function
    Public Shared Function Añadir(ByVal descEmpresa As String, ByVal pRangoEdad As ErangoEdad) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DrangoEdad.Añadir(descEmpresa, pRangoEdad)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Editar(ByVal descEmpresa As String, ByVal pRangoEdad As ErangoEdad) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DrangoEdad.Editar(descEmpresa, pRangoEdad)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Eliminar(ByVal descEmpresa As String, ByVal pRangoEdad As ErangoEdad) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DrangoEdad.Eliminar(descEmpresa, pRangoEdad)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function

    '******* RptGerenciales xComoSeEntero  *******'
    Public Shared Function rptGerenciales_xRangoEdad(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal rptGerencial As EproformaCabecera) As List(Of ErangoEdad)
        Dim rangoEdads As List(Of ErangoEdad) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                rangoEdads = DrangoEdad.rptGerenciales_xRangoEdad(descEmpresa, rptGerencial)
                If rangoEdads Is Nothing Then rangoEdads = New List(Of ErangoEdad)
                'If DisplaySelect Then accions.Insert(0, New xOperaciones("00", "-- SELECIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return rangoEdads
    End Function

End Class
